#include<bits/stdc++.h>
#define ll long long
#define rep(x,l,r) for(int x=l;x<=r;x++)

using namespace std;
const int N=3e5+10,mod=998244353;

int n,m,q,a[N],x,y;ll c1,c2;ll qpow(ll x,ll y){ll az=1;while(y){if(y&1)az=az*x%mod;x=x*x%mod;y>>=1;}return az;}
void sol(int num){
	if(!num){rep(i,1,n)rep(j,i+1,n)c1+=(a[i]>a[j]);c2++;return;}
	rep(x,1,n)rep(y,x+1,n)swap(a[x],a[y]),sol(num-1),swap(a[x],a[y]);
}

int main(){

	freopen("random.in","r",stdin);
	freopen("random.out","w",stdout);

	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m>>q;rep(i,1,n)cin>>a[i];sol(m);cout<<c1*qpow(c2,mod-2)%mod<<"\n";
	rep(i,1,q)cin>>x>>y,swap(a[x],a[y]),c1=c2=0,sol(m-i),cout<<c1*qpow(c2,mod-2)%mod<<"\n";

	return 0;
}
